<?php
/*
 * Name:      Customer
 * Directory: customers
 * Version:   1.0.0
 * Type:      user
 * UI Name:   Customers
 * UI Icon:
 */

// MODULE CONFIGURATION DEFINITION
$config = array();
$config['mod_name'] = 'suppliers';		// name the module
$config['mod_version'] = '1.0.0';		// add a version number
$config['mod_directory'] = 'suppliers';		// tell dotProject where to find this module
$config['mod_setup_class'] = 'CSetupSuppliers';	// the name of the PHP setup class (used below)
$config['mod_type'] = 'user';			// 'core' for modules distributed with dP by standard, 'user' for additional modules from dotmods
$config['mod_ui_name'] = 'Suppliers';		// the name that is shown in the main menu of the User Interface
$config['mod_ui_icon'] = 'suppliers.png';	// name of a related icon
$config['mod_description'] = '';	// some description of the module
$config['mod_config'] = true;			// show 'configure' link in viewmods

// show module configuration with the dPframework (if requested via http)
if (@$a == 'setup') {
	echo dPshowModuleConfig( $config );
}

class CSetupSuppliers {

	function configure() {		// configure this module
	global $AppUI;
		$AppUI->redirect( 'm=suppliers&a=configure' );	// load module specific configuration page
  		return true;
	}

	function remove() {		// run this method on uninstall process
		db_exec( "DROP TABLE suppliers;" );	// remove the einstein table from database
		return null;
	}


	function install() {

		$sql = "CREATE TABLE `suppliers` (
				  `sup_id` int(11) NOT NULL auto_increment,
				  `sup_code` varchar(255) NOT NULL,
				  `sup_name` varchar(255) NOT NULL,
				  `sup_status` int(11) NOT NULL COMMENT 'lookup mdstatus loai Customer',
				  `sup_type` int(11) NOT NULL COMMENT 'lookup mdtype laij Customer',
				  `sup_address` varchar(255) default NULL,
				  `sup_tel` varchar(255) default NULL,
				  `sup_fax` varchar(255) default NULL,
				  `sup_classification` int(11) default NULL,
				  `sup_vat_code` varchar(255) default NULL,
				  `sup_markup` double default '0' COMMENT 'ty le % lai',
				  `sup_division` int(11) default NULL,
				  `sup_costcenter` int(11) default NULL,
				  `sup_resource` int(11) default NULL COMMENT 'nguoi phu trach nha cung cap nay',
				  `sup_ledger1` varchar(255) NOT NULL COMMENT 'thong tin tai khoan tra 1',
				  `sup_ledger2` varchar(255) default NULL COMMENT 'thong tin tai khoan tra 2',
				  PRIMARY KEY  (`sup_id`)
				) ENGINE=MyISAM;";

		db_exec( $sql ); db_error();						// execute the queryString
	}
}

?>